﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TracNghiemTinHocDaiCuong.BIZ;
using TracNghiemTinHocDaiCuong.Common;



namespace TracNghiemTinHocDaiCuong
{
    public partial class QuanLyChuDe : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LayDanhSach();
        }

        protected void btnThemChuDe_Click(object sender, EventArgs e)
        {
            Response.Redirect("ThemChuDe.aspx");
        }

        protected void btnSuaChuDe_Click(object sender, EventArgs e)
        {
            Response.Redirect(string.Format("SuaChuDe.aspx?ID={0}", ViewState["idChuDe"]));
        }

        protected void btnXoaChuDe_Click(object sender, EventArgs e)
        {
            ChuDeBIZ.Xoa(Methods.ConvertNumber(ViewState["idChuDe"].ToString()));
            LayDanhSach();
        }

        protected void lkbtnChuDe_Click(object sender, CommandEventArgs e)
        {
            ViewState["idChuDe"] = Methods.ConvertNumber(e.CommandName);

            int i = Methods.ConvertNumber(e.CommandArgument.ToString());
            gvChuDe.Rows[i].Cells[0].CssClass = "row";
            gvChuDe.Rows[i].Cells[1].CssClass = "row";
            gvChuDe.Rows[i].Cells[2].CssClass = "row";
        }

        private void LayDanhSach()
        {
            gvChuDe.DataSource = ChuDeBIZ.LayDanhSach();
            gvChuDe.DataBind();
        }
    }
}